package com.ct.book.model;

import com.ct.book.enums.ResultCode;
import lombok.Data;

@Data
public class Result<T> {
    private ResultCode code;
    private String errMsg;
    private T data;

    public static <T> Result<T> success (T data) {
        Result result = new Result<>();;
        result.setCode(ResultCode.SUCCESS);
        result.setData(data);
        return result;
    }

    public static <T> Result<T> unlogin() {
        Result result = new Result<>();;
        result.setCode(ResultCode.UNLOGIN);
        result.setErrMsg("用户未登录");
        return result;
    }

    public static <T> Result<T> unlogin(T data) {
        Result result = new Result<>();;
        result.setCode(ResultCode.UNLOGIN);
        result.setErrMsg("用户未登录");
        result.setData(data);
        return result;
    }
}
